package com.nacosdemo.nacosdemo.controller;

import com.nacosdemo.api.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RefreshScope //打开动态刷新功能
@RequestMapping("/discovery")
public class DiscoveryController {

    @Value("${service.name}")
    private String serverName;

    @Value("${service.id}")
    private String serverId;
    @Autowired
    TestService testService;

    @GetMapping("/get")
    public String get() {
        return testService.getProviderInfo() + "nacosProvider, serverName:" + serverName + ", serverId:" + serverId;
    }
}
